//a.myachin

#include <curses.h>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <unistd.h>
#include "mmenu.c"

char *main_menu[] = {
    "New Game",
    "Load Game",
    "Instructions",
    "History",
    "Quit",
    0
};

void DisplayTitle()
{
    char *copy_txt = "Copyright (c) 2012, by Alexey Myachin.";
    char *title_txt = "Time life.";
    int cx = (COLS / 2) - (strlen(copy_txt) / 2);
    int cy = LINES - 2;
    int tx = (COLS / 2) - (strlen(title_txt) / 2);
    int ty = 3;

    attrset(COLOR_PAIR(1));
    mvprintw(cy, cx, "%s", copy_txt);
    attrset(COLOR_PAIR(2));
    mvprintw(ty, tx, "%s", title_txt);
    refresh();
    sleep(3);
}

int main(int argc, char *argv[])
{
    initscr();
    if (!has_colors()) {
        endwin();
        fprintf(stderr, "Error - no color support on this terminal\n");
        exit(1);
    }

    if (start_color() != OK) {
        endwin();
        fprintf(stderr, "Error - could not initialize colors\n");
        exit(1);
    }

    init_pair(1, COLOR_GREEN, COLOR_BLACK);
    init_pair(2, COLOR_YELLOW, COLOR_BLACK);
    init_pair(3, COLOR_CYAN, COLOR_BLACK);

    DisplayTitle();

    int choice;
    do {
        choice = get_choise(main_menu);
        switch (choice) {
        case 'q':
        case 'Q':
            choice = 'q';
            break;
        }
    } while (choice != 'q');
    endwin();

    exit(EXIT_SUCCESS);
}
